<?php
/**
 * Created by PhpStorm.
 * User: USER
 * Date: 2017/4/28
 * Time: 14:29
 */

namespace app\Http\Controllers\Order;


use App\Http\Controllers\Controller;

class OrderController extends Controller
{

    public function __construct()
    {
        $this->middleware('check.login');
    }

    /**
     * 列表页面
     */
    public function index()
    {
        $menu_id = request('curr_menu_id', 0);
        if(!$menu_id){
            return response()->json('非法操作');
        }
        $toolBarButton = $this->buildToolBarButton($menu_id);
        return view('sale.requisition.list',compact('toolBarButton','menu_id'));
    }

    public function addOrder()
    {
        $params['req_id'] = request('req_id');
        try{
            $info = callApiServer("Order.RequisitionService.getReqOne", $params);
            if(empty($info)){
                return response()->json('对应数据不存在');
            }
            return view('sale.order.list', compact("info"));
        }catch (\Exception $e){
            if($e->getCode() == 500){
                return response()->json(['code'=>500,'data'=>'后台服务异常:'.$e->getMessage()]);
            }else{
                return response()->json(['code'=>400,'data'=>$e->getMessage()]);
            }
        }
    }
}